using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class TaskSlot : MonoBehaviour
{
    public Text TaskName;
    public Text TaskDes;
    public Text TaskProgress;
    public Text TaskReward;
    public Text GetText;
    public Button Get;
    private MyTaskData Data;
    public void Init(MyTaskData Data)
    {
        this.Data = Data;
        Get.onClick.AddListener(() =>
        {
            AudioService.Instance.PlayEffect("Button");
            TaskSystem.Instance.GetTaskReward(Data.Data.TaskEnum);
        });
        TaskName.text = Data.Data.TaskNameStr;
        TaskDes.text = Data.Data.TaskDes;
        TaskReward.text = Data.Data.RewardDes;
        if (Data.Data.IsShowCount)
        {
            TaskProgress.text = Data.CurrentCount + "/" + Data.NeedCount;
        }
        else
        {
            TaskProgress.text = "未完成";
        }
        if (Data.IsComplete)
        {
            TaskProgress.text = "已完成";
            Get.interactable = true;
            GetText.text = "领取";
        }
        else
        {
            Get.interactable = false;
            GetText.text = "未完成";
        }
        if (Data.IsGet)
        {
            Get.interactable = false;
            GetText.text = "已领取";
        }
    }
}
